<template>
  <div class="telphone">
    <div class="boundText">
      <span>绑定手机号</span>
      <p>首次使用需绑定手机号</p>
    </div>
    <bound-tel></bound-tel>
  </div>
</template>

<script>
import BoundTel from "../components/boundTel";
import axios from '../api/axios';
import { docbind } from "../api/captch";
export default {
  name: "phone",
  components: { BoundTel },
  data(){
    return{

    }
  },
  created(){
    this.acquire();
  },
  methods:{
    // doclink(){
    //   axios.post("http://cs-myzx.myzx.cn/xcxcards/doctors/auth"/+sign==1,{

    //   }).then(res=>{
    //     console.log(res);
    //   })
    // }
    acquire(){
      if (localStorage.time) {
          if (Date.now() - localStorage.time >60000) {
            localStorage.clear()
            console.log(888)
          }
        } else {
          localStorage.clear()
          console.log(777)
        }
      function getAddressURLParam(paramName) {
        //构造一个含有目标参数的正则表达式的对象
        let reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)");
        //匹配目标参数
        let url = window.location.search.substr(1).match(reg);
        //返回参数值
        if (url != null)
          return unescape(url[2]);
        return null;
      }
      var test = window.location.href;
      console.log(test);
      test = decodeURIComponent(test)
      var openid = getAddressURLParam('wx_openid')
            console.log(openid);
      var nickname = getAddressURLParam('wx_nickname')
      var sex = getAddressURLParam('sex')
      //判断路由是否有wx_openid有就存着
      if (test.indexOf('wx_openid') != -1) {
        localStorage.openid = openid;
        localStorage.nickname = nickname;
        localStorage.sex = sex;
        return false;
      } else {
        //没有就判断本地是否存有
        if (localStorage.openid) {
          return false;
        } else {
          //没有就重新授权
          var test1 = window.location.href
          var name = encodeURIComponent(test1)
          //跳转到授权地址
          test1 = "http://cs-myzx.myzx.cn/xcxcards/doctors/auth"
        }
      }
    },
  }
};
</script>
<style scoped>
.telphone {
  width: 100%;
  background: url(../assets/telbg.png) no-repeat;
  background-size: contain;
  position: absolute;
  top: 0;
  bottom: 0;
  text-align: center;
}
.telphone span {
  font-size: 60px;
}
.telphone p {
  font-size: 28px;
  color: #999999;
}
.boundText{
    margin: 179px 100px 60px;
    text-align: left;
}
.boundText p{
    margin-top: 20px;
}
</style>